package com.sjqi.demo.executor;

import com.sjqi.demo.config.Configuration;
import com.sjqi.demo.config.MappedStatement;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.List;

/**
 * @author qishaojun
 */
public class SimpleExecutor extends BaseExecutor {
    @Override
    List<Object> queryFromDataBase(Configuration configuration, MappedStatement mapStatement) {
        Statement statement=null;
        ResultSet rs=null;
        List<Object> results;
        Connection connection=getConnection();
        //直接获取
        String sql = boundSql.getSql();
        //四大组件之二  Statement  PreparedStatement  CallableStatement
        //通过 statementHandler 去屏蔽不同 statement 的处理逻辑
        StatementHandler statementHandler = configuration.newStatementHandler(mapStatement);
        statement=statementHandler.prepare(mapStatement,sql,connection);
        statementHandler.parameterize(param,statement,boundSql);
        results = statementHandler.query();

        return results;
    }

    Connection getConnection(Configuration configuration) {

    }
}
